// useTables.js
import { ref, onMounted } from 'vue';
import axios from 'axios';
import request from "@/utils/request";

const tables = ref([]);

export default function useTables() {
  onMounted(async () => {
    try {

      await request.get('/tables/table-labels').then(res=>{
        console.log(res)

        tables.value = res.data.map(table => ({
          path: `${table.name}`,
          name: table.label,
          component: () => import('@/views/table/manage/SerachTable')
        }));

      })
    }
    catch (error) {
      console.error('Error fetching tables:', error);
    }
  });

  return { tables };
}

